package com.itbupt.types.event;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * @Author dingchang
 * @Date 2025/3/31 16:32
 * @Description: 消息事件基类
 */

@Data
public abstract class BaseEvent<T> {

    // data 就是 sku
    public abstract EventMessage<T> buildEventMessage(T data);

    public abstract String topic();

    /**
     * 事件消息体的基本结构
     * @param <T>
     */
    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    public static class EventMessage<T> {
        private String id;
        private Date timestamp;
        private T data;
    }

}
